<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    let ik = Math.floor(Math.random() * (10 + 1))
    console.log(ik)

    for (let i = 1; i < 20; i++) {
      let kk = +prompt("亲输入数字0~10")
      if (kk > ik) {
        alert("错了！，真他娘的背！")
      }
      if (kk < ik) {
        alert("错了！，真他娘的背！")
      }
      if (kk === ik) {
        alert("恭喜这个比，猜对了！")
        break
      }
      if (i === 8) {
        break
      }
    }
  </script>
</body>

</html>